/*
 * @Description: 单位导航包裹组件
 * @Author: Rfan
 * @Date: 2022-04-07 15:49:26
 * @LastEditTime: 2022-09-08 15:05:24
 */

import FondsNav from '@/components/FondsNav';
import { useUseRightContext } from '../contexts/UseRightContext';
import ATNav from '@/components/ATNav';

const NavSidebar = () => {
  const { selectFond, setSelectFond, setSelectAT } = useUseRightContext();

  /**
   * @description: 切换全宗回调
   * @param {number} id 全宗id
   * @param {any} item 切换的全宗
   * @return {*}
   */
  const handleChange = (id: number, item: any): any => {
    console.log('change', id, item);
    setSelectFond(item);
  };

  /**
   * @description: 切换档案类型回调
   * @param {number} atId 档案类型ID
   * @param {any} atItem 切换的档案类型
   * @return {*}
   */
  const handleATChange = (atId: number, atItem: any) => {
    console.log('list at change', { atId, atItem });
    setSelectAT(atItem);
  };

  return (
    <>
      <FondsNav onChange={handleChange} />
      <ATNav activeFond={selectFond.id} onChange={handleATChange} />
    </>
  );
};

export default NavSidebar;
